#!/bin/bash

# 正则表达式
pattern='^(feat|fix|docs|style|refactor|chore|perf|test|build|ci|revert|bump)(\([^)]+\))?: .{5,128}$'


# 读取提交信息
commit_msg_file=$1
commit_msg=$(cat "$commit_msg_file")


# 检查提交信息
if ! [[ "$commit_msg" =~ $pattern ]]; then
    echo "❌ Commit message does not match the required pattern:"
    echo "   $pattern"
    echo "🚨 Example: 'feat: add user login endpoint'"
    exit 1
fi
